package com.zyq.service.impl;

import com.zyq.model.entity.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zyq.mapper.MessageMapper;
import com.zyq.service.IMessageService;

import java.util.List;

/**
 * messageService业务层处理
 *
 * @author zyq
 * @date 2022-03-02
 */
@Service
public class MessageServiceImpl implements IMessageService
{
    @Autowired
    private MessageMapper messageMapper;

    /**
     * 查询message
     *
     * @param id messageID
     * @return message
     */
    @Override
    public Message selectMessageById(Long id)
    {
        return messageMapper.selectMessageById(id);
    }

    /**
     * 查询message列表
     *
     * @param message message
     * @return message
     */
    @Override
    public List<Message> selectMessageList(Message message)
    {
        return messageMapper.selectMessageList(message);
    }

    /**
     * 新增message
     *
     * @param message message
     * @return 结果
     */
    @Override
    public int insertMessage(Message message)
    {

        return messageMapper.insertMessage(message);
    }

    /**
     * 修改message
     *
     * @param message message
     * @return 结果
     */
    @Override
    public int updateMessage(Message message)
    {
        return messageMapper.updateMessage(message);
    }

    /**
     * 批量删除message
     *
     * @param ids 需要删除的messageID
     * @return 结果
     */
    @Override
    public int deleteMessageByIds(Long[] ids)
    {
        return messageMapper.deleteMessageByIds(ids);
    }


    /**
     * 批量更新message
     *
     * @param ids
     * @return 结果
     */
    @Override
    public int updateStatus(Long[] ids){
        return messageMapper.updateStatus(ids);
    }
    /**
     * 删除message信息
     *
     * @param id messageID
     * @return 结果
     */
    @Override
    public int deleteMessageById(Long id)
    {
        return messageMapper.deleteMessageById(id);
    }

    /**
     * 统计消息未读数
     * @param userId
     * @return
     */
    @Override
    public int countByUserId(Long userId){
        return messageMapper.countByUserId(userId);
    }

    @Override
    public int updateStatusAll(Long userId){
        return messageMapper.updateStatusAll(userId);
    }
}
